<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<th:block th:include="include :: select2-css" />
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-annualInspection-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">选择年检计划：</label>
				<div class="col-sm-8">
					<select class="form-control" id="elevatorName" name="elevatorName">
						<option value="">请选择...</option>
						<option th:each="plan : ${planList}" th:value="${plan.planId}" th:text="${plan.elevatorName}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<th:block th:include="include :: select2-js" />
    <script type="text/javascript">
		var prefix = ctx + "business/annualInspection"
		$("#form-annualInspection-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {

				var elevatorName = $("#elevatorName option:selected").html();
				var planId = $("#elevatorName option:selected").val();

				if(planId == ""){
				    $.modal.alert("请选择一个计划！");
				    return false;
				}

                $.ajax({
                    cache : true,
                    type : "POST",
                    url : prefix + "/add",
                    data : {
                        "elevatorName": elevatorName,
                        "planId": planId,
                        "remark": $("#remark").val()
                    },
                    async : false,
                    error : function(request) {
                        $.modal.alertError("系统错误");
                    },
                    success : function(data) {
                        $.operate.successCallback(data);
                    }
                });
	        }
	    }
	</script>
</body>
</html>
